<html lang="zh-cn">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>自己建立的上传与下载</title>
    <!-- Bootstrap -->
    <link href="../dist/css/bootstrap.min.css" rel="stylesheet">
  </head>
  <body>
    
    <div class="bg-danger">
    <form  action="./upload1.php" method="post" enctype="multipart/form-data" class="table table-striped" style="width: 1000px; margin: 0 auto 10px;">
    <!-- enctype是确保上传文件的正确编码 -->
      <input type="file" name="file[]" multiple="multiple"  >
      <!-- multiple="multiple"可接受多个值的文件上传 -->
      <input type="submit" value="上传">


    </form>
    </div>



    <table class="table table-striped" style="width: 1000px; margin: 0 auto 10px;">
      <thead>
        <tr >
          <th scope="col" >序列号</th>
          <th scope="col" >图片预览</th>
          <th scope="col" >文件名</th>
          <th scope="col" >文件大小</th>
          <th scope="col" >上传时间</th>
          <th scope="col" >下载</th>
          <th scope="col" >删除操作</th>
        </tr>
      </thead>
      <tbody >
      <?php  foreach ($file_array as $key => $value) { ?>
        
        <tr >
          <th ><?php echo ($key+1)  ?></th>
          <th ><img src="<?php echo $value  ?>" alt="" style="width:50px;heigth:40px"></th>
          <th ><code><?php echo basename($value)  ?></code></th>
          <td ><?php echo filesize($value)  ?></td>
          <td ><?php echo date("Y-m-d h:i:s",filemtime($value))   ?></td>
          <td ><a href="<?php echo $value ?>" download="<?php echo basename($value)  ?>" class="btn btn-sm btn-success">下载</a></td>
          <!-- a标签的download属性 也可以新建一个php作为下载执行-->
          <td ><a href="./del.php?id=<?php echo $key; ?>" onclick="confirm('确认是否删除')" class="btn btn-sm btn-danger">删除</a></td>
         
        </tr>
        <?php }  ?>
        
      
      </tbody>
    </table>
    
  </body>
</html>
